//
//  BkAuthorDetailViewController.m
//  TuDianEducation
//
//  Created by lixinkeji on 2021/1/14.
//  Copyright © 2021 zhangbenchao. All rights reserved.
//

#import "BkAuthorDetailViewController.h"
#import "BkAuthorDetailHeader.h"
@interface BkAuthorDetailViewController ()
@property (nonatomic,strong) UITableView *tableView;
@property (nonatomic,strong) BkAuthorDetailHeader *headerView;

@property (nonatomic,strong) NSDictionary *dataDic;
@end

@implementation BkAuthorDetailViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self.view addSubview:self.tableView];
    self.title = @"作者详情";
    [self requstgetauthordetail];
    [self getauthorgoodslist];
}
-(BkAuthorDetailHeader *)headerView{
    if (!_headerView) {
        _headerView = [[BkAuthorDetailHeader alloc]init];
    }
    return _headerView;
}
-(UITableView *)tableView{
    if (!_tableView) {
        _tableView = [[UITableView alloc]initWithFrame:CGRectMake(0, 0, TSScreenWidth, TSScreenHeight - Height_NavBar) style:(UITableViewStyleGrouped)];
      
        _tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
        _tableView.tableHeaderView = self.headerView;
       
        if (@available(iOS 11.0, *))
        {
            _tableView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
            _tableView.estimatedRowHeight = 0;
            _tableView.estimatedSectionHeaderHeight = 0;
            _tableView.estimatedSectionFooterHeight = 0;
        }
        else
        {
            self.automaticallyAdjustsScrollViewInsets = NO;
        }
        
    }
    return _tableView;
}
#pragma mark ---请求作者详情数据

-(void)requstgetauthordetail{
    NSDictionary * pamas = @{@"aid":_aid};
    [NetWorkTools postConJSONWithUrl:@"getauthordetail" parameters:pamas success:^(id responseObject) {
        NSString *result = responseObject[@"result"];
        NSString *resultNote = responseObject[@"resultNote"];
        NSDictionary *dataobject = responseObject[@"dataobject"];
        if (result.integerValue == 0) {
            self.headerView.dataDic = dataobject;
        }else{
            [MBProgressHUD showError:resultNote];
        }
    } fail:^(NSError *error) {
        
    }];
}
-(void)setDataDic:(NSDictionary *)dataDic{
    _dataDic = dataDic;
}
#pragma mark ----作者代表作

-(void)getauthorgoodslist
{
    NSDictionary * pamas = @{@"aid":_aid,@"nowPage":@"1",@"pageCount":@"15"};
    [NetWorkTools postConJSONWithUrl:@"getauthorgoodslist" parameters:pamas success:^(id responseObject) {
        NSString *result = responseObject[@"result"];
        NSString *resultNote = responseObject[@"resultNote"];
        NSArray *dataList = responseObject[@"dataList"];
        if (result.integerValue == 0) {
            self.headerView.dataArray = dataList;
        }else{
            [MBProgressHUD showError:resultNote];
        }
    } fail:^(NSError *error) {
        
    }];
}




@end
